<?php
include_once("DBCORE.cls.php");
	class db_CateRes
	{
		private $tablename = "tblcateres";
		private $db;
		function __construct()
		{
			$this->db = new DBCORE;
			$this->db->db_connect("localhost", "root", "","restaurant");
			$this->db->db_query("SET NAMES 'UTF8'");
		}
		function select($id)
		{
			$id = !empty($id)? "WHERE RestaurantID = '{$id}'":"";
			$myStrSQL = "SELECT * FROM {$this->tablename} {$id}";
			$data = $this->db->db_fetch_assoc($this->db->db_query($myStrSQL));
			return $data;
		}
		function selectAll()
		{
			$myStrSQL = "SELECT * FROM {$this->tablename} WHERE 1";
			$result = $this->db->db_query($myStrSQL);
			$resArray = array();
			while($row = $this->db->db_fetch_assoc($result))
			{
				$resArray[] = $row;
			}
			return $resArray;			
		}
		function update($update = array(), $condistion)
		{
			if(empty($condistion))
				return
			$update = "RestaurantID ={$update['RestaurantID']},Description={$update['Description']},rootPath={$update['rootPath']},webPath={$update['webPath']}";
			$condistion = "WHERE RestaurantID = '{$condistion}'";
			$myStrSQL = "UPDATE {$this->tablename} SET {$update} WHERE {$condistion}";			
			$data = $this->db->db_affected_rows();
			return $data;
		}
	}
/*$getImageRes = new db_CateRes();
		$image = $getImageRes->select('RE0003');
		$rootPath = $image['rootPath'].$image['Description'].$image['Type'];
		echo $rootPath;*/
?>